package com.hxh.basic.project.controller;


import com.hxh.basic.project.entity.ClubForumInfo;
import com.hxh.basic.project.form.forum.AddForumForm;
import com.hxh.basic.project.service.IClubForumInfoService;
import com.hxh.basic.project.utils.ResultVoUtil;
import com.hxh.basic.project.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zouyujie
 * @since 2022-11-09
 */
@CrossOrigin
@RestController
@RequestMapping("/club-forum-info")
public class ClubForumInfoController {

    @Resource
    private IClubForumInfoService clubForumInfoService;

    @PostMapping("/add")
    public ResultVo add(@RequestBody AddForumForm addForumForm){
        System.out.println(addForumForm);
        Boolean result = clubForumInfoService.saveForumInfo(addForumForm);
        if(result){
            return ResultVoUtil.success();
        }
        return ResultVoUtil.error("发送失败！");
    }

    @PostMapping("/list")
    public ResultVo list(){
        List<ClubForumInfo> result = clubForumInfoService.list();
        return ResultVoUtil.success(result);
    }

    @PostMapping("/detail/{id}")
    public ResultVo detail(@PathVariable("id") Integer id){
        return ResultVoUtil.success(clubForumInfoService.getById(id));
    }

}
